let t = require;
let  e = module
let  o =  e.exports;
 o.default =  e.exports;

                'use strict';
                console.log("start");
                var _n155,
                    i =
                    (this && this.__extends) ||
                    ((_n155 = function n(t, e) {
                            return (_n155 =
                                Object.setPrototypeOf ||
                                ({
                                        __proto__: []
                                    }
                                    instanceof Array &&
                                    function(t, e) {
                                        t.__proto__ = e;
                                    }) ||
                                function(t, e) {
                                    for (var o in e) {
                                        Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                                    }
                                })(t, e);
                        }),
                        function(t, e) {
                            function o() {
                                this.constructor = t;
                            }
                            _n155(t, e),
                                (t.prototype =
                                    null === e ?
                                    Object.create(e) :
                                    ((o.prototype = e.prototype), new o()));
                        });
                Object.defineProperty(o, '__esModule', {
                        value: !0
                    }),
                    (o.SoldierCtrl = void 0);
                var r = t('SoldierActor'),
                    a = t('MathUtils'),
                    s = t('AbsInfo'),
                    c = t('AbsCtrl'),
                    l = t('ArrayUtils'),
                    u = t('BattleUtils'),
                    h = t('IdleToAct'),
                    p = t('BattleMrg'),
                    f = (function(t) {
                        function e(e) {
                            var o = t.call(this, e) || this;
                            return (o._camp = 1), o;
                        }
                        return (
                            i(e, t),
                            (e.prototype.setGrid = function(t) {
                                for (var e = 0; e < t.length; e++) {
                                    for (var o = t[e], n = 0; n < o.length; n++) {
                                        var i = o[n];
                                        i.on(
                                                p.BattleEvent.SoldierChanged,
                                                this.onSoldierChangedHandler,
                                                this
                                            ),
                                            i.data && this.onSoldierChangedHandler(i);
                                    }
                                }
                                this._grid = t;
                            }),
                            (e.prototype.onSoldierChangedHandler = function(t) {
                                var e = this._scene.getActorBy(t.col, t.row);
                                if (t.data && t.data.type <= 3)
                                    e ?
                                    e.setInfo(t.data.soldierId) :
                                    (((e = new r.SoldierActor(t.data.soldierId)).col = t.col),
                                        (e.row = t.row),
                                        (e.entity.x =
                                            u.default.ColStart + e.col * u.default.ColSpace),
                                        (e.entity.y =
                                            u.default.RowStart - e.row * u.default.RowSpace),
                                        (e.entity.zIndex = a.default.getZIndex(-e.entity.y)),
                                        (t.soldier = e),
                                        this._scene.addActor(e),
                                        this._battlers.push(e),
                                        e.idle()),
                                    e.setGridCard(t.card);
                                else {
                                    if (e) {
                                        var o = this;
                                        cc.tween(e.entity)
                                            .to(
                                                0.3, {
                                                    scale: 0
                                                }, {
                                                    easing: 'elasticIn'
                                                }
                                            )
                                            .call(function() {
                                                o.removeHandler(e);
                                            })
                                            .start();
                                    }
                                    t.soldier = null;
                                }
                            }),
                            (e.prototype.removeHandler = function(t) {
                                this.remove(t, !0);
                            }),
                            (e.prototype.onStart = function() {
                                (this._battlers = l.ArrayUtils.toRandomList(this._battlers)),
                                (this._battleIndex = u.default.SoldierWarCount),
                                (this._dieCount = 0);
                                for (var t = 0; t < this._battlers.length; t++) {
                                    t < this._battleIndex ?
                                        this._battlers[t].appear() :
                                        this._battlers[t].awaitTo();
                                }
                            }),
                            (e.prototype.onStop = function() {
                                for (var t = 0; t < this._battlers.length; t++) {
                                    this._battlers[t].revive(),
                                        this._battlers[t].act(h.IdleToAct);
                                }
                            }),
                            (e.prototype.onUpdate = function() {
                                for (var t = 0, e = 0, o = 0; o < this._battlers.length; o++) {
                                    (i = this._battlers[o]).hp <= 0 && e++, (t += i.hp);
                                }
                                if (e > this._dieCount) {
                                    var n = e - this._dieCount;
                                    for (o = 0; o < n; o++) {
                                        var i;
                                        (i = this._battlers[this._battleIndex++]) && i.appear();
                                    }
                                    this._dieCount = e;
                                }
                                this._hp != t &&
                                    ((this._hp = t),
                                        t > this._hpMax && (this._hpMax = t),
                                        this.emit(s.InfoEvent.HPChanged, this));
                            }),
                            (e.prototype.destroy = function() {
                                if (this._grid) {
                                    for (var e = 0; e < this._grid.length; e++) {
                                        for (var o = this._grid[e], n = 0; n < o.length; n++) {
                                            o[n].targetOff(this);
                                        }
                                    }
                                    this._grid = null;
                                }
                                t.prototype.destroy.call(this);
                            }),
                            e
                        );
                    })(c.AbsCtrl);
                (o.SoldierCtrl = f), console.log("end");
            module.exports =  e.exports;